import 'package:decimal/decimal.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_cwhisky/bean/good_entity.dart';
import 'package:flutter_cwhisky/common/style/images.dart';
import 'package:flutter_cwhisky/component/business/good/base_good_view.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../../bean/mall_home_entity.dart';
import '../../../common/style/colors.dart';
import '../../../store/user_state.dart';
import '../../image_view.dart';
import '../../text_view.dart';

class GoodHorizontalComponent extends BaseGoodComponent {
  GoodHorizontalComponent({super.key, required super.good});

  @override
  Widget build(BuildContext context) {
    handlePrice();
    return Container(
      padding: EdgeInsets.only( top: 10.r),
      child: Row(

        children: [
          Container(
            margin: EdgeInsets.only(top: 6.r,left: 4.r),
            decoration: BoxDecoration(borderRadius: BorderRadius.circular(6.r), color: AppColors.white),

            child: Stack(
              alignment: Alignment.center,
              children: [
                ImageView(
                  url: good.image ?? '',
                  width: 90.r,
                  height: 90.r,
                ),
                good.balanceCount! <= 0
                    ? ImageView(
                        url: 'assets/images/icon_good_sold_out.png',
                        width: 40.r,
                        height: 40.r,
                      )
                    : const SizedBox(),
              ],
            ),
          ),
          Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Padding(
                padding: EdgeInsets.only(top: 14.r),
                child: TextView(
                  text: good.enName ?? '',
                  fontSize: 12.sp,
                  fontColor: AppColors.color332B29,
                  fontWeight: FontWeight.w700,
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                ),
              ),
              Padding(
                padding: EdgeInsets.only(top: 5.r),
                child: TextView(
                  text: good.cnName ?? '',
                  fontSize: 12.sp,
                  fontColor: AppColors.color332B29,
                  fontWeight: FontWeight.w500,
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                ),
              ),
              Padding(
                padding: EdgeInsets.only(top: 5.r),
                child: TextView(
                  text: good.goodsCode ?? '',
                  fontSize: 10.sp,
                  fontColor: AppColors.color99,
                  fontWeight: FontWeight.w400,
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                ),
              ),
              Padding(
                padding: EdgeInsets.only(top: 21.r),
                child: Row(
                  children: [
                    Expanded(
                      child: TextView(
                        text: price,
                        fontColor: AppColors.color332B29,
                        fontSize: 18.sp,
                        fontWeight: FontWeight.w900,
                      ),
                    ),
                    Padding(
                      padding: EdgeInsets.all(4.r),
                      child: ImageView(
                        url: AppImages.tabCartNormal,
                        width: 16.r,
                        height: 16.r,
                      ),
                    )
                  ],
                ),
              ),
              Padding(
                padding: EdgeInsets.only(
                  top: 6.r,
                ),
                child: Row(
                  children: [
                    TextView(
                      text: orgPrice,
                      fontColor: showLine ? AppColors.color99 : AppColors.color332B29,
                      fontSize: 12.sp,
                      fontWeight: showLine ? FontWeight.w400 : FontWeight.w500,
                      decoration: showLine ? TextDecoration.lineThrough : TextDecoration.none,
                    ),
                    showLabel
                        ? Container(
                            margin: EdgeInsets.only(left: 6.r),
                            width: 30.r,
                            height: 14.r,
                            alignment: Alignment.center,
                            decoration: const BoxDecoration(color: AppColors.color332B29),
                            child: TextView(
                              text: '会员价',
                              fontSize: 8.sp,
                              fontColor: const Color(0xffEFD3A7),
                            ),
                          )
                        : const SizedBox(
                            width: 30,
                            height: 14,
                          )
                  ],
                ),
              )
            ],
          ))
        ],
      ),
    );
  }
}
